<template>
  <div class="mold-dispatch-root">
    <div class="top-title">
      <vab-icon class="icon" icon="speaker-3-fill" />
      <div style="flex: 1; line-height: 18px">
        <div style="font-size: 16px; font-weight: bold">
          {{ _prop.dispatchData?.moldName || '' }}
        </div>
        <div style="font-size: 14px">
          <label style="margin-right: 3px; color: #444">
            {{ _prop.dispatchData?.moldCode || '' }}
          </label>
          <label style="margin-right: 3px; color: #444">
            {{ _prop.dispatchData?.wcName || '' }}
          </label>
          <label style="font-weight: bold; color: #fbc339">
            {{ _prop.dispatchData?.corpName || '' }}
          </label>
        </div>
      </div>
      <el-button
        size="small"
        style="padding: 2px"
        type="primary"
        @click="toChangeOrder"
      >
        换单
      </el-button>
    </div>
    <div class="body-content">
      <template v-if="_prop.dispatchData.useMold">
        <div
          v-for="(dispatchItem, mIndex) in _prop.dispatchData.dispatches"
          :key="mIndex"
        >
          <div class="content-item">
            <div class="item-title">
              <div style="flex: 1">
                <div>
                  <label class="dispatch-code">
                    {{ dispatchItem.dispatchCode }}
                  </label>
                  <label class="dispatch-inv-name">
                    {{ dispatchItem.invname }}
                  </label>
                </div>
                <div class="dispatch-inv-code">{{ dispatchItem.invcode }}</div>
              </div>
              <el-tag
                v-if="dispatchItem.isShoujian"
                size="small"
                style="padding: 2px"
                type="warning"
              >
                首检
              </el-tag>
            </div>
            <div class="item-qty-root">
              <div style="flex: 1">
                <div class="qty-title">工单数</div>
                <div class="dispatch-qty">{{ dispatchItem.dispatchQty }}</div>
              </div>
              <div
                style="width: 1.5px; height: 20px; background-color: #ccc"
              ></div>
              <div style="flex: 1">
                <div class="qty-title">报工数</div>
                <div class="report-in-qty">{{ dispatchItem.reportQty }}</div>
              </div>
              <div
                style="width: 1.5px; height: 20px; background-color: #ccc"
              ></div>
              <div style="flex: 1">
                <div class="qty-title">入库数</div>
                <div class="report-in-qty">{{ dispatchItem.inQty }}</div>
              </div>
            </div>
          </div>
        </div>
      </template>
      <template v-else>
        <div class="body-content-item">
          <div class="label">
            <vab-icon icon="article-line" style="font-size: 16px" />
            派工单
          </div>
          <div class="content">
            {{ _prop.dispatchData?.dispatchCode || '' }}
          </div>
        </div>
        <div class="body-content-item">
          <div class="label">
            <vab-icon icon="slack-line" style="font-size: 16px" />
            产品
          </div>
          <div class="content">
            <div style="font-size: 14px; line-height: 18px; color: #555">
              {{ _prop.dispatchData?.invcode || '' }}
            </div>
            <div style="line-height: 18px">
              {{ _prop.dispatchData?.invname || '' }}
            </div>
          </div>
        </div>

        <div class="body-content-item">
          <div class="label">
            <vab-icon icon="chat-poll-line" style="font-size: 16px" />
            工单数
          </div>
          <div class="content">{{ _prop.dispatchData?.dispatchQty }}</div>
        </div>

        <div class="body-content-item">
          <div class="label">
            <vab-icon
              icon="file-list-2-line"
              style="font-size: 16px; color: #1890ff"
            />
            报工数
          </div>
          <div class="content" style="color: #1890ff">
            {{ _prop.dispatchData?.reportQty }}
          </div>
        </div>

        <div class="body-content-item">
          <div class="label">
            <vab-icon
              icon="calendar-check-fill"
              style="font-size: 16px; color: #4bbf83"
            />
            合格数
          </div>
          <div class="content" style="color: #4bbf83">
            {{ _prop.dispatchData?.qualifiedQty }}
          </div>
        </div>

        <div class="body-content-item">
          <div class="label">
            <vab-icon
              icon="file-shield-2-line"
              style="font-size: 16px; color: #ffba00"
            />
            报检数
          </div>
          <div class="content" style="color: #ffba00">
            {{ _prop.dispatchData?.declareQty }}
          </div>
        </div>

        <div class="body-content-item">
          <div class="label">
            <vab-icon
              icon="spam-2-line"
              style="font-size: 16px; color: #c45656"
            />
            报废数
          </div>
          <div class="content" style="color: #c45656">
            {{ _prop.dispatchData?.scrapQty }}
          </div>
        </div>

        <div class="body-content-item">
          <div class="label">
            <vab-icon
              icon="indent-increase"
              style="font-size: 16px; color: #1890ff"
            />
            入库数
          </div>
          <div class="content" style="color: #1890ff">
            {{ _prop.dispatchData?.inQty }}
          </div>
        </div>

        <!-- qualifiedQty 合格数 -->
        <!-- declareQty 报检数 -->
        <!-- scrapQty 报废数 -->
      </template>
    </div>
    <div class="bottom-footer">
      <div style="padding: 0 6px; text-align: center">
        {{ _prop.dispatchData?.createUser || '' }}
      </div>
      <div style="flex: 1; text-align: center">
        {{ _prop.dispatchData?.banciDate || '' }}
        &nbsp;&nbsp;
        {{ _prop.dispatchData?.banciName || '' }}
      </div>
      <div class="option">{{ _prop.dispatchData?.opName || '' }}</div>
    </div>
  </div>
</template>
<script setup>
  const _prop = defineProps({
    dispatchData: {
      type: Object,
      default: () => {},
    },
  })
  const toChangeOrder = () => {
    _emits('toChangeOrder')
  }
  const _emits = defineEmits('toChangeOrder')
</script>
<style lang="scss" scoped>
  .mold-dispatch-root {
    background-color: #e0e1e2;
    border-radius: 5px;
    .top-title {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: center;
      padding: 0 3px;
      line-height: 16px;
      border-bottom: 1.5px solid #ccc;
      .icon {
        font-size: 32px;
        line-height: 36px;
      }
    }
    .body-content {
      width: 100%;
      padding-bottom: 6px;
      .body-content-item {
        display: flex;
        align-items: center;
        padding: 0px 6px 0 6px;
        line-height: 28px;
        .label {
          width: 80px;
          font-size: 12px;
          font-weight: 500;
          color: #888;
        }
        .content {
          flex: 1;
          font-size: 14px;
          color: #333;
        }
      }

      .content-item {
        border-bottom: 1.5px solid #f0f1f2;
        .item-title {
          display: flex;
          flex-direction: row;
          align-items: center;
          padding: 6px 3px;
          font-size: 12px;
          line-height: 18px;
          .dispatch-code {
            margin-right: 3px;
            font-weight: bold;
            color: #666;
          }
          .dispatch-inv-name {
            font-size: 700;
            color: #333;
          }
          .dispatch-inv-code {
            font-weight: bold;
            color: #666;
          }
        }
        .item-qty-root {
          display: flex;
          flex-direction: row;
          align-items: center;
          line-height: 24px;
          text-align: center;
          .qty-title {
            font-size: 14px;
            color: #666;
          }
          .dispatch-qty {
            font-size: 18px;
            font-weight: 500;
            color: #333;
          }
          .report-in-qty {
            font-size: 18px;
            font-weight: bold;
            color: #1890ff;
          }
        }
      }
    }
    .bottom-footer {
      display: flex;
      align-items: center;
      width: 100%;
      height: 35px;
      font-size: 14px;
      border-top: 1.5px solid #ccc;
      .option {
        padding: 0 6px;
        font-weight: bold;
        text-align: center;
      }
    }
  }
</style>
